package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxx.server.mapper.TdakaMapper;
import com.xxxx.server.pojo.Admin;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.pojo.Tdaka;
import com.xxxx.server.service.ITdakaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 教职工打卡表 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-01
 */
@Service
public class TdakaServiceImpl extends ServiceImpl<TdakaMapper, Tdaka> implements ITdakaService {

    @Autowired
    private TdakaMapper tdakaMapper;

    @Override
    public List<Tdaka> getTdakaByTDid() {
        return tdakaMapper.getTdakaByTDid(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }

    @Override
    public RespPageBean getTdakaByPage(Integer currentPage, Integer size, Tdaka tdaka, String[] beginDateScope) {
        //开启分页
        Page<Tdaka> page = new Page<>(currentPage,size);
        IPage<Tdaka> TdakaByPage = tdakaMapper.getTdakaByPage(page, tdaka, beginDateScope);
        RespPageBean respPageBean = new RespPageBean(TdakaByPage.getTotal(), TdakaByPage.getRecords());
        return respPageBean;

    }

    @Override
    public List<Tdaka> getTdaka(Integer id) {
        return tdakaMapper.getTdaka(id);
    }


}
